/*
** Copyright (C) 2009 Joshua Brent Marsh <joshua@icub3d.com>
**  
** This file is part of icub3d-adt
**
** icub3d-adt is free sofware; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 3 of the License, or
** (at your option) any later version.
**  
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**  
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**  
*/

/* $Id$ */

#ifndef ICUB3D_TREE_H
#define ICUB3D_TREE_H 1

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdarg.h>

#include "list.h"
#include "function_prototypes.h"

typedef
struct tree_node
{
  struct tree_node *parent;
  List *children;
  void *item;
} TreeNode;

TreeNode * tree_node_create (TreeNode *parent, void *item, 
			     size_t children, ...);

void tree_node_destroy (TreeNode *node, destroy_func *dfunc, int dchildren);

int tree_node_add_child (TreeNode *node, TreeNode *child);
int tree_node_remove_child (TreeNode *node, TreeNode *child);
List * tree_node_children (TreeNode *node);
void tree_node_clear_children (TreeNode *node);

TreeNode * tree_node_find_root (TreeNode *node);

size_t tree_node_height (TreeNode *node);
size_t tree_node_depth (TreeNode *node);
size_t tree_node_descendants (TreeNode *node);

#endif /* ICUB3D_TREE_H */
